package com.xl.type;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: lei·xie
 * @Created: 2024/3/12 0012 11:28
 */
public class TypeConversionDemo {
    public static void main(String[] args) {

        int a1 = 20;
        byte b = (byte)a1;
        System.out.println(a1);
        System.out.println(b);

        int a2 = 1500;
        byte a3 = (byte) a2;
        System.out.println(a2);
        System.out.println(a3);

        double a4 = 123.456;
        int a5 = (int) a4;
        System.out.println(a4);
        System.out.println(a5);

        byte b1 = 2;
        byte b2 = 3;
        //byte b3 = b1 + b2; //b1+b2会自动转为int进行计算，所以会报错
        byte b3 = b1 += b2;  //b1+=b2= (b1的类型)b1+b2,在这里b1的类型是byte，所以b1+b2会自动转为byte进行计算
    }
}
